home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / demo / wemdemo4.zip / INFO / ELISP.19 < prev    next >
Text File  |  1994-09-21  |  52KB  |  1,234 lines

  1. Info file elisp, produced by Makeinfo, -*- Text -*- from input file
  2. elisp.texi.
  3.  
  4.    This file documents GNU Emacs Lisp.
  5.  
  6.    This is edition 1.03 of the GNU Emacs Lisp Reference Manual,   for
  7. Emacs Version 18.
  8.  
  9.    Published by the Free Software Foundation, 675 Massachusetts
  10. Avenue,  Cambridge, MA 02139 USA
  11.  
  12.    Copyright (C) 1990 Free Software Foundation, Inc.
  13.  
  14.    Permission is granted to make and distribute verbatim copies of
  15. this manual provided the copyright notice and this permission notice
  16. are preserved on all copies.
  17.  
  18.    Permission is granted to copy and distribute modified versions of
  19. this manual under the conditions for verbatim copying, provided that
  20. the entire resulting derived work is distributed under the terms of a
  21. permission notice identical to this one.
  22.  
  23.    Permission is granted to copy and distribute translations of this
  24. manual into another language, under the above conditions for modified
  25. versions, except that this permission notice may be stated in a
  26. translation approved by the Foundation.
  27.  
  28.  
  29. 
  30. File: elisp,  Node: Indent Tabs,  Next: Motion by Indent,  Prev: Relative Indent,  Up: Indentation
  31.  
  32. Adjustable "Tab Stops"
  33. ----------------------
  34.  
  35.    This section explains the mechanism for user-specified "tab stops"
  36. and the mechanisms which use and set them.  The name "tab stops" is
  37. used because the feature is similar to that of the tab stops on a
  38. typewriter.  The feature works by inserting an appropriate number of
  39. spaces and tab characters to reach the designated position, like the
  40. other indentation functions; it does not affect the display of tab
  41. characters in the buffer (*note Control Char Display::.).  Note that
  42. the TAB character as input uses this tab stop feature only in a few
  43. major modes, such as Text mode.
  44.  
  45.  * Function: tab-to-tab-stop
  46.      This function inserts spaces or tabs up to the next tab stop
  47.      column defined by `tab-stop-list'.  It searches the list for an
  48.      element greater than the current column number, and uses that
  49.      element as the column to indent to.  If no such element is
  50.      found, then nothing is done.
  51.  
  52.  * User Option: tab-stop-list
  53.      This variable is the list of tab stop columns used by
  54.      `tab-to-tab-stops'.  The elements should be integers in
  55.      increasing order.  The tab stop columns need not be evenly spaced.
  56.  
  57.      Use `M-x edit-tab-stops' to edit the location of tab stops
  58.      interactively.
  59.  
  60.  
  61. 
  62. File: elisp,  Node: Motion by Indent,  Prev: Indent Tabs,  Up: Indentation
  63.  
  64. Indentation-Based Motion Commands
  65. ---------------------------------
  66.  
  67.    These commands, primarily for interactive use, act based on the
  68. indentation in the text.
  69.  
  70.  * Command: back-to-indentation
  71.      This command moves point to the first non-whitespace character
  72.      in the current line (which is the line in which point is
  73.      located).  It returns `nil'.
  74.  
  75.  * Command: backward-to-indentation ARG
  76.      This command moves point backward ARG lines and then to the
  77.      first nonblank character on that line.  It returns `nil'.
  78.  
  79.  * Command: forward-to-indentation ARG
  80.      This command moves point forward ARG lines and then to the first
  81.      nonblank character on that line.  It returns `nil'.
  82.  
  83.  
  84. 
  85. File: elisp,  Node: Columns,  Next: Case Changes,  Prev: Indentation,  Up: Text
  86.  
  87. Counting Columns
  88. ================
  89.  
  90.    The column functions convert between a character position
  91. (counting characters from the beginning of the buffer) and a column
  92. position (counting screen characters from the beginning of a line).
  93.  
  94.    Column number computations ignore the width of the window and the
  95. amount of horizontal scrolling.  Consequently, a column value can be
  96. arbitrarily high.  The first (or leftmost) column is numbered 0.
  97.  
  98.    A character counts according to the number of columns it occupies
  99. on the screen.  This means control characters count as occupying 2 or
  100. 4 columns, depending upon the value of `ctl-arrow', and tabs count as
  101. occupying a number of columns that depends on the value of
  102. `tab-width' and on the column where the tab begins.  *Note Control
  103. Char Display::.
  104.  
  105.  * Function: current-column
  106.      This function returns the horizontal position of point, measured
  107.      in columns, counting from 0 at the left margin.  The column
  108.      count is calculated by adding together the widths of all the
  109.      displayed representations of the characters between the start of
  110.      the current line and point.
  111.  
  112.      For a more complicated example of the use of `current-column',
  113.      see the description of `count-lines' in *Note Text Lines::.
  114.  
  115.  * Function: move-to-column COLUMN
  116.      This function moves point to COLUMN in the current line.  The
  117.      calculation of COLUMN takes into account the widths of all the
  118.      displayed representations of the characters between the start of
  119.      the line and point.
  120.  
  121.      If the argument COLUMN is greater than the column position of
  122.      the end of the line, point moves to the end of the line.  If
  123.      COLUMN is negative, point moves to the beginning of the line. 
  124.      An error is signaled if COLUMN is not an integer.
  125.  
  126.      The return value is the column number actually moved to.
  127.  
  128.  
  129. 
  130. File: elisp,  Node: Case Changes,  Next: Substitution,  Prev: Columns,  Up: Text
  131.  
  132. Case Changes
  133. ============
  134.  
  135.    The case change commands described here work on text in the
  136. current buffer.  *Note Character Case::, for case conversion commands
  137. that work on strings and characters.
  138.  
  139.  * Command: capitalize-region START END
  140.      This function capitalizes all words in the region defined by
  141.      START and END.  To capitalize means to convert each word's first
  142.      character to upper case and convert the rest of each word to
  143.      lower case.  The function returns `nil'.
  144.  
  145.      If one end of the region is in the middle of a word, the part of
  146.      the word within the region is treated as an entire word.
  147.  
  148.      When `capitalize-region' is called interactively, START and END
  149.      are point and the mark, with the smallest first.
  150.  
  151.           ---------- Buffer: foo ----------
  152.           This is the contents of the 5th foo.
  153.           ---------- Buffer: foo ----------
  154.           
  155.           (capitalize-region 1 44)
  156.           => nil
  157.  
  158.              ---------- Buffer: foo ----------
  159.           This Is The Contents Of The 5th Foo.
  160.           ---------- Buffer: foo ----------
  161.  
  162.  * Command: downcase-region START END
  163.      This function converts all of the letters in the region defined
  164.      by START and END to lower case.  The function returns `nil'.
  165.  
  166.      When `downcase-region' is called interactively, START and END
  167.      are point and the mark, with the smallest first.
  168.  
  169.  * Command: upcase-region START END
  170.      This function converts all of the letters in the region defined
  171.      by START and END to upper case.  The function returns `nil'.
  172.  
  173.      When `upcase-region' is called interactively, START and END are
  174.      point and the mark, with the smallest first.
  175.  
  176.  * Command: capitalize-word COUNT
  177.      This function capitalizes COUNT words after point, moving point
  178.      over as it does.  To capitalize means to convert each word's
  179.      first character to upper case and convert the rest of each word
  180.      to lower case.  If COUNT is negative, the function capitalizes
  181.      the -COUNT previous words but does not move point.  The value is
  182.      `nil'.
  183.  
  184.      If point is in the middle of a word, the part of word the before
  185.      point (if moving forward) or after point (if operating backward)
  186.      is ignored.  The rest is treated as an entire word.
  187.  
  188.      When `capitalize-word' is called interactively, COUNT is set to
  189.      the numeric prefix argument.
  190.  
  191.  * Command: downcase-word COUNT
  192.      This function converts the COUNT words after point to all lower
  193.      case, moving point over as it does.  If COUNT is negative, it
  194.      converts the -COUNT previous words but does not move point.  The
  195.      value is `nil'.
  196.  
  197.      When `downcase-word' is called interactively, COUNT is set to
  198.      the numeric prefix argument.
  199.  
  200.  * Command: upcase-word COUNT
  201.      This function converts the COUNT words after point to all upper
  202.      case, moving point over as it does.  If COUNT is negative, it
  203.      converts the -COUNT previous words but does not move point.  The
  204.      value is `nil'.
  205.  
  206.      When `upcase-word' is called interactively, COUNT is set to the
  207.      numeric prefix argument.
  208.  
  209.  
  210. 
  211. File: elisp,  Node: Substitution,  Next: Underlining,  Prev: Case Changes,  Up: Text
  212.  
  213. Substituting for a Character Code
  214. =================================
  215.  
  216.    The following function replaces characters within a specified
  217. region based on their character code.
  218.  
  219.  * Function: subst-char-in-region START END OLD-CHAR NEW-CHAR
  220.           &optional NOUNDO
  221.      This function replaces all occurrences of the character OLD-CHAR
  222.      with the character NEW-CHAR in the region of the current buffer
  223.      defined by START and END.
  224.  
  225.      If NOUNDO is non-`nil', then `subst-char-in-region' does not
  226.      record the change for undo and does not mark the buffer as
  227.      modified.  This feature is useful for changes which are not
  228.      considered significant, such as when Outline mode changes
  229.      visible lines to invisible lines and vice versa.
  230.  
  231.      `subst-char-in-region' does not move point and returns `nil'.
  232.  
  233.           ---------- Buffer: foo ----------
  234.           This is the contents of the buffer before.
  235.           ---------- Buffer: foo ----------
  236.           
  237.           (subst-char-in-region 1 20 ?i ?X)
  238.                => nil
  239.           
  240.           ---------- Buffer: foo ----------
  241.           ThXs Xs the contents of the buffer before.
  242.           ---------- Buffer: foo ----------
  243.  
  244.  
  245. 
  246. File: elisp,  Node: Underlining,  Next: Registers,  Prev: Substitution,  Up: Text
  247.  
  248. Underlining
  249. ===========
  250.  
  251.    The underlining commands are somewhat obsolete.  The
  252. `underline-region' function actually inserts `_^H' before each
  253. appropriate character in the region.  This command provides a minimal
  254. text formatting feature that might work on your printer; however, we
  255. recommend instead that you use more powerful text formatting
  256. facilities, such as Texinfo.
  257.  
  258.  * Command: underline-region START END
  259.      This function underlines all nonblank characters in the region
  260.      defined by START and END.  That is, an underscore character and
  261.      a backspace character are inserted just before each
  262.      non-whitespace character in the region.  The backspace
  263.      characters are intended to cause overstriking, but in Emacs they
  264.      display as either `\010' or `^H', depending on the setting of
  265.      `ctl-arrow'.  There is no way to see the effect of the
  266.      overstriking within Emacs.  The value is `nil'.
  267.  
  268.  * Command: ununderline-region START END
  269.      This function removes all underlining (overstruck underscores)
  270.      in the region defined by START and END.  The value is `nil'.
  271.  
  272.  
  273. 
  274. File: elisp,  Node: Registers,  Prev: Underlining,  Up: Text
  275.  
  276. Registers
  277. =========
  278.  
  279.    A register is a sort of variable used in Emacs editing that can
  280. hold a marker, a string, or a rectangle.  Each register is named by a
  281. single character.  All characters, including control and meta
  282. characters (but with the exception of `C-g'), can be used to name
  283. registers.  Thus, there are 255 possible registers.  A register is
  284. designated in Emacs Lisp by a character which is its name.
  285.  
  286.    The functions in this section return unpredictable values unless
  287. otherwise stated.
  288.  
  289.  * Variable: register-alist
  290.      This variable is an alist of elements of the form `(NAME . 
  291.      CONTENTS)'.  Normally, there is one element for each Emacs
  292.      register that has been used.
  293.  
  294.      The object NAME is a character (an integer) identifying the
  295.      register.  The object CONTENTS is a string, marker, or list
  296.      representing the register contents.  A string represents text
  297.      stored in the register.  A marker represents a position.  A list
  298.      represents a rectangle; its elements are strings, one per line
  299.      of the rectangle.
  300.  
  301.  * Command: view-register REG
  302.      This command displays what is contained in register REG.
  303.  
  304.  * Function: get-register REG
  305.      This function returns the contents of the register REG, or `nil'
  306.      if it has no contents.
  307.  
  308.  * Function: set-register REG VALUE
  309.      This function sets the contents of register REG to VALUE.  A
  310.      register can be set to any value, but the other register
  311.      functions expect only strings, markers, and lists.
  312.  
  313.  * Command: point-to-register REG
  314.      This command stores both the current location of point and the
  315.      current buffer in register REG as a marker.
  316.  
  317.  * Command: register-to-point REG
  318.      This command moves point to the position stored in register REG.
  319.      Since both the buffer and the location within the buffer are
  320.      stored by the `point-to-register' function, this command can
  321.      switch you to another buffer.
  322.  
  323.      If the register does not contain a saved position (a marker),
  324.      then an error is signaled.
  325.  
  326.  * Command: insert-register REG &optional BEFOREP
  327.      This command inserts contents of register REG into the current
  328.      buffer.
  329.  
  330.      Normally, this command puts point before the inserted text, and
  331.      the mark after it.  However, if the optional second argument
  332.      BEFOREP is non-`nil', it puts the mark before and point after. 
  333.      You can pass a non-`nil' second argument BEFOREP to this
  334.      function interactively by supplying any prefix argument.
  335.  
  336.      If the register contains a rectangle, then the rectangle is
  337.      inserted with its upper left corner at point.  This means that
  338.      text is inserted in the current line and underneath it on
  339.      successive lines.
  340.  
  341.      If the register contains something other than saved text (a
  342.      string) or a rectangle (a list), currently useless things
  343.      happen.  This may be changed in the future.
  344.  
  345.  * Command: copy-to-register REG START END &optional DELETE-FLAG
  346.      This command copies the region from START to END into register
  347.      REG.  If DELETE-FLAG is non-`nil', it deletes the region from
  348.      the buffer after copying it into the register.
  349.  
  350.  * Command: prepend-to-register REG START END &optional DELETE-FLAG
  351.      This command prepends the region from START to END into register
  352.      REG.  If DELETE-FLAG is non-`nil', it deletes the region from
  353.      the buffer after copying it to the register.
  354.  
  355.  * Command: append-to-register REG START END &optional DELETE-FLAG
  356.      This command appends the region from START to END to the text
  357.      already in register REG.  If DELETE-FLAG is non-`nil', it
  358.      deletes the region from the buffer after copying it to the
  359.      register.
  360.  
  361.  * Command: copy-rectangle-to-register REG START END &optional
  362.           DELETE-FLAG
  363.      This command copies a rectangular region from START to END into
  364.      register REG.  If DELETE-FLAG is non-`nil', it deletes the
  365.      region from the buffer after copying it to the register.
  366.  
  367.  
  368. 
  369. File: elisp,  Node: Searching and Matching,  Next: Syntax Tables,  Prev: Text,  Up: Top
  370.  
  371. Searching and Matching
  372. **********************
  373.  
  374.    GNU Emacs provides two ways to search through a buffer for
  375. specified text: exact string searches and regular expression
  376. searches.  After a regular expression search, you can identify the
  377. text matched by parts of the regular expression by examining the
  378. "match data".
  379.  
  380. * Menu:
  381.  
  382. * String Search::         Search for an exact match.
  383. * Regular Expressions::   Describing classes of strings.
  384. * Regexp Search::         Searching for a match for a regexp.
  385. * Match Data::            Finding out which part of the text matched
  386.                             various parts of a regexp, after regexp search.
  387. * Saving Match Data::     Saving and restoring this information.
  388. * Standard Regexps::      Useful regexps for finding sentences, pages,...
  389. * Searching and Case::    Case-independent or case-significant searching.
  390.  
  391.  
  392. 
  393. File: elisp,  Node: String Search,  Next: Regular Expressions,  Prev: Searching and Matching,  Up: Searching and Matching
  394.  
  395. Searching for Strings
  396. =====================
  397.  
  398.    These are the primitive functions for searching through the text
  399. in a buffer.  They are meant for use in programs, but you may call
  400. them interactively.  If you do so, they prompt for the search string;
  401. LIMIT and NOERROR are set to `nil', and REPEAT is set to 1.
  402.  
  403.  * Command: search-forward STRING &optional LIMIT NOERROR REPEAT
  404.      This function searches forward from point for an exact match for
  405.      STRING.  It sets point to the end of the occurrence found, and
  406.      returns `t'.  If no match is found, the value and side effects
  407.      depend on NOERROR.
  408.  
  409.      In the following example, point is positioned at the beginning
  410.      of the line.  Then `(search-forward "fox")' is evaluated in the
  411.      minibuffer and point is left after the last letter of `fox':
  412.  
  413.           ---------- Buffer: foo ----------
  414.           -!-The quick brown fox jumped over the lazy dog.
  415.           ---------- Buffer: foo ----------
  416.           
  417.           (search-forward "fox")
  418.                => t
  419.           
  420.           ---------- Buffer: foo ----------
  421.           The quick brown fox-!- jumped over the lazy dog.
  422.           ---------- Buffer: foo ----------
  423.  
  424.      If LIMIT is non-`nil', then it is the upper bound to the search.
  425.      (It must be a position in the current buffer.)  No match
  426.      extending after that position is accepted.
  427.  
  428.      What happens when the search fails depends on the value of
  429.      NOERROR.  If NOERROR is `nil', a `search-failed' error is
  430.      signaled.  If NOERROR is `t', `search-forward' returns `nil' and
  431.      doesn't signal an error.  If NOERROR is neither `nil' nor `t',
  432.      then `search-forward' moves point to LIMIT and returns `nil'.
  433.  
  434.      If REPEAT is non-`nil', then the search is repeated that many
  435.      times.  Point is positioned at the end of the last match.
  436.  
  437.  * Command: search-backward STRING &optional LIMIT NOERROR REPEAT
  438.      This function searches backward from point for STRING.  It is
  439.      just like `search-forward' except that it searches backwards and
  440.      leaves point at the beginning of the match.
  441.  
  442.  * Command: word-search-forward STRING &optional LIMIT NOERROR REPEAT
  443.      This function searches forward from point for a "word" match for
  444.      STRING.  It sets point to the end of the occurrence found, and
  445.      returns `t'.
  446.  
  447.      A word search differs from a simple string search in that a word
  448.      search *requires* that the words it searches for are present as
  449.      entire words (searching for the word `ball' will not match the
  450.      word `balls'), and punctuation and spacing are ignored
  451.      (searching for `ball boy' will match `ball.  Boy!').
  452.  
  453.      In this example, point is first placed at the beginning of the
  454.      buffer; the search leaves it between the `y' and the `!'.
  455.  
  456.           ---------- Buffer: foo ----------
  457.           -!-He said "Please!  Find
  458.           the ball boy!"
  459.           ---------- Buffer: foo ----------
  460.           
  461.           (word-search-forward "Please find the ball, boy.")
  462.                => t
  463.           
  464.           ---------- Buffer: foo ----------
  465.           He said "Please!  Find
  466.           the ball boy-!-!"
  467.           ---------- Buffer: foo ----------
  468.  
  469.      If LIMIT is non-`nil' (it must be a position in the current
  470.      buffer), then it is the upper bound to the search.  The match
  471.      found must not extend after that position.
  472.  
  473.      If NOERROR is `t', then `word-search-forward' returns `nil' when
  474.      a search fails, instead of signaling an error.  If NOERROR is
  475.      neither `nil' nor `t', then `word-search-forward' moves point to
  476.      LIMIT and returns `nil'.
  477.  
  478.      If REPEAT is non-`nil', then the search is repeated that many
  479.      times.  Point is positioned at the end of the last match.
  480.  
  481.  * Command: word-search-backward STRING &optional LIMIT NOERROR REPEAT
  482.      This function searches backward from point for a word match to
  483.      STRING.  This function is just like `word-search-forward' except
  484.      that it searches backward and normally leaves point at the
  485.      beginning of the match.
  486.  
  487.  
  488. 
  489. File: elisp,  Node: Regular Expressions,  Next: Regexp Search,  Prev: String Search,  Up: Searching and Matching
  490.  
  491. Regular Expressions
  492. ===================
  493.  
  494.    A "regular expression" ("regexp", for short) is a pattern that
  495. denotes a (possibly infinite) set of strings.  Searching for matches
  496. for a regexp is a very powerful operation.  This section explains how
  497. to write regexps; the following section says how to search for them.
  498.  
  499. * Menu:
  500.  
  501. * Syntax of Regexps::       Rules for writing regular expressions.
  502. * Regexp Example::          Illustrates regular expression syntax.
  503.  
  504.  
  505. 
  506. File: elisp,  Node: Syntax of Regexps,  Next: Regexp Example,  Prev: Regular Expressions,  Up: Regular Expressions
  507.  
  508. Syntax of Regular Expressions
  509. -----------------------------
  510.  
  511.    Regular expressions have a syntax in which a few characters are
  512. special constructs and the rest are "ordinary".  An ordinary
  513. character is a simple regular expression which matches that character
  514. and nothing else.  The special characters are `$', `^', `.', `*',
  515. `+', `?', `[', `]' and `\'; no new special characters will be defined
  516. in the future.  Any other character appearing in a regular expression
  517. is ordinary, unless a `\' precedes it.
  518.  
  519.    For example, `f' is not a special character, so it is ordinary,
  520. and therefore `f' is a regular expression that matches the string `f'
  521. and no other string.  (It does *not* match the string `ff'.) 
  522. Likewise, `o' is a regular expression that matches only `o'.
  523.  
  524.    Any two regular expressions A and B can be concatenated.  The
  525. result is a regular expression which matches a string if A matches
  526. some amount of the beginning of that string and B matches the rest of
  527. the string.
  528.  
  529.    As a simple example, we can concatenate the regular expressions
  530. `f' and `o' to get the regular expression `fo', which matches only
  531. the string `fo'.  Still trivial.  To do something more powerful, you
  532. need to use one of the special characters.  Here is a list of them:
  533.  
  534. `. (Period)'
  535.      is a special character that matches any single character except
  536.      a newline.  Using concatenation, we can make regular expressions
  537.      like `a.b' which matches any three-character string which begins
  538.      with `a' and ends with `b'.
  539.  
  540. `*'
  541.      is not a construct by itself; it is a suffix that means the
  542.      preceding regular expression is to be repeated as many times as
  543.      possible.  In `fo*', the `*' applies to the `o', so `fo*'
  544.      matches one `f' followed by any number of `o's.  The case of
  545.      zero `o's is allowed: `fo*' does match `f'.
  546.  
  547.      `*' always applies to the *smallest* possible preceding
  548.      expression.  Thus, `fo*' has a repeating `o', not a repeating
  549.      `fo'.
  550.  
  551.      The matcher processes a `*' construct by matching, immediately,
  552.      as many repetitions as can be found.  Then it continues with the
  553.      rest of the pattern.  If that fails, backtracking occurs,
  554.      discarding some of the matches of the `*'-modified construct in
  555.      case that makes it possible to match the rest of the pattern. 
  556.      For example, matching `ca*ar' against the string `caaar', the
  557.      `a*' first tries to match all three `a's; but the rest of the
  558.      pattern is `ar' and there is only `r' left to match, so this try
  559.      fails.  The next alternative is for `a*' to match only two `a's.
  560.      With this choice, the rest of the regexp matches successfully.
  561.  
  562. `+'
  563.      is a suffix character similar to `*' except that it must match
  564.      the preceding expression at least once.  So, for example, `ca+r'
  565.      will match the strings `car' and `caaaar' but not the string
  566.      `cr', whereas `ca*r' would match all three strings.
  567.  
  568. `?'
  569.      is a suffix character similar to `*' except that it can match
  570.      the preceding expression either once or not at all.  For
  571.      example, `ca?r' will match `car' or `cr'; nothing else.
  572.  
  573. `[ ... ]'
  574.      `[' begins a "character set", which is terminated by a `]'.  In
  575.      the simplest case, the characters between the two form the set. 
  576.      Thus, `[ad]' matches either one `a' or one `d', and `[ad]*'
  577.      matches any string composed of just `a's and `d's (including the
  578.      empty string), from which it follows that `c[ad]*r' matches
  579.      `cr', `car', `cdr', `caddaar', etc.
  580.  
  581.      Character ranges can also be included in a character set, by
  582.      writing two characters with a `-' between them.  Thus, `[a-z]'
  583.      matches any lower case letter.  Ranges may be intermixed freely
  584.      with individual characters, as in `[a-z$%.]', which matches any
  585.      lower case letter or `$', `%' or a period.
  586.  
  587.      Note that the usual special characters are not special any more
  588.      inside a character set.  A completely different set of special
  589.      characters exists inside character sets: `]', `-' and `^'.
  590.  
  591.      To include a `]' in a character set, make it the first character.
  592.      For example, `[]a]' matches `]' or `a'.  To include a `-', write
  593.      `--', which is a range containing only `-', or write `-' as the
  594.      first character in the range.
  595.  
  596.      To include `^', make it other than the first character in the set.
  597.  
  598. `[^ ... ]'
  599.      `[^' begins a "complement character set", which matches any
  600.      character except the ones specified.  Thus, `[^a-z0-9A-Z]'
  601.      matches all characters *except* letters and digits.
  602.  
  603.      `^' is not special in a character set unless it is the first
  604.      character.  The character following the `^' is treated as if it
  605.      were first (thus, `-' and `]' are not special there).
  606.  
  607.      Note that a complement character set can match a newline, unless
  608.      newline is mentioned as one of the characters not to match.
  609.  
  610. `^'
  611.      is a special character that matches the empty string, but only
  612.      at the beginning of a line in the text being matched.  Otherwise
  613.      it fails to match anything.  Thus, `^foo' matches a `foo' which
  614.      occurs at the beginning of a line.
  615.  
  616.      When matching a string, `^' matches at the beginning of the
  617.      string or after a newline character `\n'.
  618.  
  619. `$'
  620.      is similar to `^' but matches only at the end of a line.  Thus,
  621.      `x+$' matches a string of one `x' or more at the end of a line.
  622.  
  623.      When matching a string, `$' matches at the end of the string or
  624.      before a newline character `\n'.
  625.  
  626. `\'
  627.      has two functions: it quotes the special characters (including
  628.      `\'), and it introduces additional special constructs.
  629.  
  630.      Because `\' quotes special characters, `\$' is a regular
  631.      expression which matches only `$', and `\[' is a regular
  632.      expression which matches only `[', and so on.
  633.  
  634.      Note that `\' also has special meaning in the read syntax of
  635.      Lisp strings (*note String Type::.), and must be quoted with
  636.      `\'.  For example, the regular expression that matches the `\'
  637.      character is `\\'.  To write a Lisp string that contains `\\',
  638.      Lisp syntax requires you to quote each `\' with another `\'. 
  639.      Therefore, the read syntax for this string is `"\\\\"'.
  640.  
  641.    *Note:* for historical compatibility, special characters are
  642. treated as ordinary ones if they are in contexts where their special
  643. meanings make no sense.  For example, `*foo' treats `*' as ordinary
  644. since there is no preceding expression on which the `*' can act.  It
  645. is poor practice to depend on this behavior; better to quote the
  646. special character anyway, regardless of where it appears.
  647.  
  648.    For the most part, `\' followed by any character matches only that
  649. character.  However, there are several exceptions: characters which,
  650. when preceded by `\', are special constructs.  Such characters are
  651. always ordinary when encountered on their own.  Here is a table of
  652. `\' constructs:
  653.  
  654. `\|'
  655.      specifies an alternative.  Two regular expressions A and B with
  656.      `\|' in between form an expression that matches anything that
  657.      either A or B matches.
  658.  
  659.      Thus, `foo\|bar' matches either `foo' or `bar' but no other
  660.      string.
  661.  
  662.      `\|' applies to the largest possible surrounding expressions. 
  663.      Only a surrounding `\( ... \)' grouping can limit the grouping
  664.      power of `\|'.
  665.  
  666.      Full backtracking capability exists to handle multiple uses of
  667.      `\|'.
  668.  
  669. `\( ... \)'
  670.      is a grouping construct that serves three purposes:
  671.  
  672.        1. To enclose a set of `\|' alternatives for other operations.
  673.           Thus, `\(foo\|bar\)x' matches either `foox' or `barx'.
  674.  
  675.        2. To enclose a complicated expression for a suffix character
  676.           such as `*' to operate on.  Thus, `ba\(na\)*' matches
  677.           `bananana', etc., with any (zero or more) number of `na'
  678.           strings.
  679.  
  680.        3. To record a matched substring for future reference.
  681.  
  682.      This last application is not a consequence of the idea of a
  683.      parenthetical grouping; it is a separate feature which happens
  684.      to be assigned as a second meaning to the same `\( ... \)'
  685.      construct because there is no conflict in practice between the
  686.      two meanings.  Here is an explanation of this feature:
  687.  
  688. `\DIGIT'
  689.      after the end of a `\( ... \)' construct, the matcher remembers
  690.      the beginning and end of the text matched by that construct. 
  691.      Then, later on in the regular expression, you can use `\'
  692.      followed by DIGIT to mean "match the same text matched the
  693.      DIGITth time by the `\( ... \)' construct."
  694.  
  695.      The strings matching the first nine `\( ... \)' constructs
  696.      appearing in a regular expression are assigned numbers 1 through
  697.      9 in the order that the open parentheses appear in the regular
  698.      expression.  `\1' through `\9' can be used to refer to the text
  699.      matched by the corresponding `\( ... \)' construct.
  700.  
  701.      For example, `\(.*\)\1' matches any newline-free string that is
  702.      composed of two identical halves.  The `\(.*\)' matches the
  703.      first half, which may be anything, but the `\1' that follows
  704.      must match the same exact text.
  705.  
  706. `\`'
  707.      matches the empty string, provided it is at the beginning of the
  708.      buffer.
  709.  
  710. `\''
  711.      matches the empty string, provided it is at the end of the buffer.
  712.  
  713. `\b'
  714.      matches the empty string, provided it is at the beginning or end
  715.      of a word.  Thus, `\bfoo\b' matches any occurrence of `foo' as a
  716.      separate word.  `\bballs?\b' matches `ball' or `balls' as a
  717.      separate word.
  718.  
  719. `\B'
  720.      matches the empty string, provided it is *not* at the beginning
  721.      or end of a word.
  722.  
  723. `\<'
  724.      matches the empty string, provided it is at the beginning of a
  725.      word.
  726.  
  727. `\>'
  728.      matches the empty string, provided it is at the end of a word.
  729.  
  730. `\w'
  731.      matches any word-constituent character.  The editor syntax table
  732.      determines which characters these are.  *Note Syntax Tables::.
  733.  
  734. `\W'
  735.      matches any character that is not a word-constituent.
  736.  
  737. `\sCODE'
  738.      matches any character whose syntax is CODE.  Here CODE is a
  739.      character which represents a syntax code: thus, `w' for word
  740.      constituent, `-' for whitespace, `(' for open parenthesis, etc. 
  741.      *Note Syntax Tables::, for a list of the codes.
  742.  
  743. `\SCODE'
  744.      matches any character whose syntax is not CODE.
  745.  
  746.    Not every string is a valid regular expression.  For example, any
  747. string with unbalanced square brackets is invalid, and so is a string
  748. that ends with a single `\'.  If an invalid regular expression is
  749. passed to any of the search functions, an `invalid-regexp' error is
  750. signaled.
  751.  
  752.  * Function: regexp-quote STRING
  753.      This function returns a regular expression string which matches
  754.      exactly STRING and nothing else.  This allows you to request an
  755.      exact string match when calling a function that wants a regular
  756.      expression.
  757.  
  758.           (regexp-quote "^The cat$")
  759.                => "\\^The cat\\$"
  760.  
  761.      One use of `regexp-quote' is to combine an exact string match
  762.      with context described as a regular expression.  For example,
  763.      this searches for the string which is the value of `string',
  764.      surrounded by whitespace:
  765.  
  766.           (re-search-forward (concat "\\s " (regexp-quote string) "\\s "))
  767.  
  768.  
  769. 
  770. File: elisp,  Node: Regexp Example,  Prev: Syntax of Regexps,  Up: Regular Expressions
  771.  
  772. Complex Regexp Example
  773. ----------------------
  774.  
  775.    Here is a complicated regexp, used by Emacs to recognize the end
  776. of a sentence together with any whitespace that follows.  It is the
  777. value of the variable `sentence-end'.
  778.  
  779.    First, we show the regexp as a string in Lisp syntax to enable you
  780. to distinguish the spaces from the tab characters.  The string
  781. constant begins and ends with a double-quote.  `\"' stands for a
  782. double-quote as part of the string, `\\' for a backslash as part of
  783. the string, `\t' for a tab and `\n' for a newline.
  784.  
  785.      "[.?!][]\"')}]*\\($\\|\t\\|  \\)[ \t\n]*"
  786.  
  787.    In contrast, if you evaluate the variable `sentence-end', you will
  788. see the following:
  789.  
  790.      sentence-end
  791.      =>
  792.      "[.?!][]\"')}]*\\($\\|  \\|  \\)[       
  793.      ]*"
  794.  
  795. In this case, the tab and carriage return are the actual characters.
  796.  
  797.    This regular expression contains four parts in succession and can
  798. be deciphered as follows:
  799.  
  800. `[.?!]'
  801.      The first part of the pattern consists of three characters, a
  802.      period, a question mark and an exclamation mark, within square
  803.      brackets.  The match must begin with one of these three
  804.      characters.
  805.  
  806. `[]\"')}]*'
  807.      The second part of the pattern matches any closing braces and
  808.      quotation marks, zero or more of them, that may follow the
  809.      period, question mark or exclamation mark.  The `\"' is Lisp
  810.      syntax for a double-quote in a string.  The `*' at the end
  811.      indicates that the immediately preceding regular expression (a
  812.      character set, in this case) may be repeated zero or more times.
  813.  
  814. `\\($\\|\t\\|  \\)'
  815.      The third part of the pattern matches the whitespace that
  816.      follows the end of a sentence: the end of a line, or a tab, or
  817.      two spaces.  The double backslashes are needed to prevent Emacs
  818.      from reading the parentheses and vertical bars as part of the
  819.      search pattern; the parentheses are used to mark the group and
  820.      the vertical bars are used to indicated that the patterns to
  821.      either side of them are alternatives.  The dollar sign is used
  822.      to match the end of a line.  The tab character is written using
  823.      `\t' and the two spaces are written as themselves.
  824.  
  825. `[ \t\n]*'
  826.      Finally, the last part of the pattern indicates that the end of
  827.      the line or the whitespace following the period, question mark
  828.      or exclamation mark may, but need not, be followed by additional
  829.      whitespace.
  830.  
  831.  
  832. 
  833. File: elisp,  Node: Regexp Search,  Next: Match Data,  Prev: Regular Expressions,  Up: Searching and Matching
  834.  
  835. Regular Expression Searching
  836. ============================
  837.  
  838.    In GNU Emacs, you can search for the next match for a regexp
  839. either incrementally or not.  Incremental search commands are
  840. described in the ``The GNU Emacs Manual''.  *Note : (emacs)Regexp
  841. Search.  Here we describe only the search functions useful in
  842. programs.  The principal is `re-search-forward'.
  843.  
  844.  * Command: re-search-forward REGEXP &optional LIMIT NOERROR REPEAT
  845.      This function searches forward in the current buffer for a
  846.      string of text that is matched by the regular expression REGEXP.
  847.      The function skips over any amount of text that is not matched
  848.      by REGEXP, and leaves point at the end of the first string found
  849.      that does match.
  850.  
  851.      If the search is successful (i.e., if text matching REGEXP is
  852.      found), then point is left at the end of that text, and the
  853.      function returns `t'.
  854.  
  855.      What happens when the search fails depends on the value of
  856.      NOERROR.  If NOERROR is `nil', a `search-failed' error is
  857.      signaled.  If NOERROR is `t', `re-search-forward' returns `nil'
  858.      and doesn't signal an error.  If NOERROR is neither `nil' nor
  859.      `t', then `search-forward' moves point to LIMIT and returns `nil'.
  860.  
  861.      If LIMIT is non-`nil' (it must be a position in the current
  862.      buffer), then it is the upper bound to the search.  No match
  863.      extending after that position is accepted.
  864.  
  865.      If REPEAT is supplied (it must be a positive number), then the
  866.      search is repeated that many times (each time starting at the
  867.      end of the previous time's match).  The call succeeds if all
  868.      these searches succeeded, and point is left at the end of the
  869.      match found by the last search.  Otherwise the search fails.
  870.  
  871.      In the following example, point is initially located directly
  872.      before the `T'.  After evaluating the form, point is located at
  873.      the end of that line (between the `t' of `hat' and before the
  874.      newline).
  875.  
  876.           ---------- Buffer: foo ----------
  877.           I read "-!-The cat in the hat
  878.           comes back" twice.
  879.           ---------- Buffer: foo ----------
  880.           
  881.           (re-search-forward "[a-z]+" nil t 5)
  882.                => t
  883.           
  884.           ---------- Buffer: foo ----------
  885.           I read "The cat in the hat-!-
  886.           comes back" twice.
  887.           ---------- Buffer: foo ----------
  888.  
  889.  * Command: re-search-backward REGEXP &optional LIMIT NOERROR REPEAT
  890.      This function searches backward in the current buffer for a
  891.      string of text that is matched by the regular expression REGEXP,
  892.      leaving point at the beginning of the first text found.
  893.  
  894.      This function is analogous to `re-search-forward', but they are
  895.      not simple mirror images.  `re-search-forward' finds the match
  896.      whose beginning is as close as possible.  If
  897.      `re-search-backward' were a perfect mirror image, it would find
  898.      the match whose end is as close as possible.  However, in fact
  899.      it finds the match whose beginning is as close as possible.  The
  900.      reason is that matching a regular expression at a given spot
  901.      always works from beginning to end, and is done at a specified
  902.      beginning position.  Thus, true mirror-image behavior would
  903.      require a special feature for matching regexps from end to
  904.      beginning.
  905.  
  906.  * Function: string-match REGEXP STRING &optional START
  907.      This function returns the index of the start of the first match
  908.      for the regular expression REGEXP in STRING, or `nil' if there
  909.      is no match.  If START is non-`nil', the search starts at that
  910.      index in STRING.
  911.  
  912.      For example,
  913.  
  914.           (string-match "quick" "The quick brown fox jumped quickly.")
  915.                => 4
  916.           (string-match "quick" "The quick brown fox jumped quickly." 8)
  917.                => 27
  918.  
  919.      The index of the first character of the string is 0, the index
  920.      of the second character is 1, and so on.
  921.  
  922.      After this function returns, the index of the first character
  923.      beyond the match is available as `(match-end 0)'.  *Note Match
  924.      Data::.
  925.  
  926.           (string-match "quick" "The quick brown fox jumped quickly." 8)
  927.                => 27
  928.           
  929.           (match-end 0)
  930.                => 32
  931.  
  932.      The `match-end' function is described along with
  933.      `match-beginning'; see *Note Match Data::.
  934.  
  935.  * Function: looking-at REGEXP
  936.      This function determines whether the text in the current buffer
  937.      directly following point matches the regular expression REGEXP. 
  938.      "Directly following" means precisely that: the search is
  939.      "anchored" and it must succeed starting with the first character
  940.      following point.  The result is `t' if so, `nil' otherwise.
  941.  
  942.      Point is not moved, but the match data is updated and can be
  943.      used with `match-beginning' or `match-end'.  *Note Match Data::.
  944.  
  945.      In this example, point is located directly before the `T'.  If
  946.      it were anywhere else, the result would be `nil'.
  947.  
  948.              ---------- Buffer: foo ----------
  949.           I read "-!-The cat in the hat
  950.           comes back" twice.
  951.           ---------- Buffer: foo ----------
  952.  
  953.              (looking-at "The cat in the hat$")
  954.                => t
  955.  
  956.  
  957. 
  958. File: elisp,  Node: Match Data,  Next: Saving Match Data,  Prev: Regexp Search,  Up: Searching and Matching
  959.  
  960. The Match Data
  961. ==============
  962.  
  963.    Emacs keeps track of the positions of the start and end of
  964. segments of text found during a regular expression search.  This
  965. means, for example, that you can search for a complex pattern, such
  966. as a date in an Rmail message, and extract parts of it.
  967.  
  968.  * Function: match-beginning COUNT
  969.      This function returns the position of the start of text matched
  970.      by the last regular expression searched for.  COUNT, a number,
  971.      specifies a subexpression whose start position is the value.  If
  972.      COUNT is zero, then the value is the position of the text
  973.      matched by the whole regexp.  If COUNT is greater than zero,
  974.      then the value is the position of the beginning of the text
  975.      matched by the COUNTth subexpression, regardless of whether it
  976.      was used in the final match.
  977.  
  978.      Subexpressions of a regular expression are those expressions
  979.      grouped inside of parentheses, `\(...\)'.  The COUNTth
  980.      subexpression is found by counting occurrences of `\(' from the
  981.      beginning of the whole regular expression.  The first
  982.      subexpression is numbered 1, the second 2, and so on.
  983.  
  984.      The `match-end' function is similar to the `match-beginning'
  985.      function except that it returns the position of the end of the
  986.      matched text.
  987.  
  988.      Here is an example, with a comment showing the numbers of the
  989.      positions in the text:
  990.  
  991.           (string-match "\\(qu\\)\\(ick\\)" "The quick fox jumped quickly.")
  992.                => 4                         ;^^^^^^^^^^
  993.                                             ;0123456789      
  994.           
  995.           (match-beginning 1)               ; The beginning of the match
  996.                => 4                         ; with `qu' is at index 4.
  997.           
  998.           (match-beginning 2)               ; The beginning of the match
  999.                => 6                         ; with `ick' is at index 6.
  1000.           
  1001.           (match-end 1)                     ; The end of the match
  1002.                => 6                         ; with `qu' is at index 6.
  1003.           
  1004.           (match-end 2)                     ; The end of the match
  1005.                => 9                         ; with `ick' is at index 9.
  1006.  
  1007.       Here is another example.  Before the form is evaluated, point is
  1008.      located at the beginning of the line.  After evaluating the
  1009.      search form, point is located on the line between the space and
  1010.      the word `in'.  The beginning of the entire match is at the 9th
  1011.      character of the buffer (`T'), and the beginning of the match
  1012.      for the first subexpression is at the 13th character (`c').
  1013.  
  1014.           (list
  1015.             (re-search-forward "The \\(cat \\)")
  1016.             (match-beginning 0)
  1017.             (match-beginning 1))
  1018.           => (t 9 13)
  1019.           
  1020.           ---------- Buffer: foo ----------
  1021.           I read "The cat -!-in the hat comes back" twice.
  1022.                   ^   ^
  1023.                   9  13
  1024.           ---------- Buffer: foo ----------
  1025.  
  1026.      (Note that in this case, the index returned is a buffer
  1027.      position; the first character of the buffer counts as 1.)
  1028.  
  1029.      It is essential that `match-beginning' be called after the
  1030.      search desired, but before any other searches are performed. 
  1031.      `match-beginning' may not give the desired results if any other
  1032.      Lisp programs are executed between the search and it, since they
  1033.      may do other searches.  This example shows misuse of
  1034.      `match-beginning'.
  1035.  
  1036.           (re-search-forward "The \\(cat \\)")
  1037.                => t
  1038.           (foo)                   ; Perhaps `foo' does more regexp searching.
  1039.           (match-beginning 0)
  1040.                => 61              ; Unexpected result!
  1041.  
  1042.       See the discussion of `store-match-data' for an example of how
  1043.      to save and restore the match data around a search.
  1044.  
  1045.  * Function: match-end COUNT
  1046.      This function returns the position of the end of text matched by
  1047.      the last regular expression searched for.  This function is
  1048.      otherwise similar to `match-beginning'.
  1049.  
  1050.  * Function: replace-match REPLACEMENT &optional FIXEDCASE LITERAL
  1051.      This function replaces the text matched by the last search with
  1052.      REPLACEMENT.
  1053.  
  1054.      If FIXEDCASE is non-`nil', then the case of the replacement text
  1055.      is not changed; otherwise, the replacement text is converted to
  1056.      a different case depending upon the capitalization of the text
  1057.      to be replaced.  If the original text is all upper case, the
  1058.      replacement text is converted to upper case, except when all of
  1059.      the words in the original text are only one character long.  In
  1060.      that event, the replacement text is capitalized.  If *all* of
  1061.      the words in the original text are capitalized, then all of the
  1062.      words in the replacement text are capitalized.
  1063.  
  1064.      If LITERAL is non-`nil', then REPLACEMENT is inserted exactly as
  1065.      it is, the only alterations being case changes as needed.  If it
  1066.      is `nil' (the default), then the character `\' is treated
  1067.      specially.  If a `\' appears in REPLACEMENT, then it must be
  1068.      part of one of the following sequences:
  1069.  
  1070.     `\&'
  1071.           `\&' stands for the entire text being replaced.
  1072.  
  1073.     `\N'
  1074.           `\N' stands for the Nth subexpression in the original
  1075.           regexp.  Subexpressions are those expressions grouped
  1076.           inside of `\(...\)'.  N is a digit.
  1077.  
  1078.     `\\'
  1079.           `\\' stands for a single `\' in the replacement text.
  1080.  
  1081.      `replace-match' leaves point at the end of the replacement text,
  1082.      and returns `t'.
  1083.  
  1084.  
  1085. 
  1086. File: elisp,  Node: Saving Match Data,  Next: Standard Regexps,  Prev: Match Data,  Up: Searching and Matching
  1087.  
  1088. Saving and Restoring the Match Data
  1089. ===================================
  1090.  
  1091.  * Function: match-data
  1092.      This function returns a new list containing all the information
  1093.      on what text the last search matched.  Element zero is the
  1094.      position of the beginning of the match for the whole expression;
  1095.      element one is the position of the end of the match for the
  1096.      expression.  The next two elements are the positions of the
  1097.      beginning and end of the match for the first subexpression.  In
  1098.      general, element
  1099.  
  1100.         number 2N
  1101.  
  1102.      corresponds to `(match-beginning N)'; and element
  1103.  
  1104.         number 2N + 1
  1105.  
  1106.      corresponds to `(match-end N)'.
  1107.  
  1108.      All the elements are markers, or the integer 0 for a match at
  1109.      the beginning of a string (with `string-match'), or `nil' if
  1110.      there was no match for that subexpression.  As with other
  1111.      functions that get information about a search, there must be no
  1112.      possibility of intervening searches between the call to a search
  1113.      function and the call to `match-data' that is intended to save
  1114.      the match-data for that search.
  1115.  
  1116.           (match-data)
  1117.                =>  (#<marker at 9 in foo> #<marker at 17 in foo>
  1118.                     #<marker at 13 in foo> #<marker at 17 in foo>)
  1119.  
  1120.      In version 19, all elements will be markers or `nil' if matching
  1121.      was done on a buffer, and all will be integers or `nil' if
  1122.      matching was done on a string with `string-match'.
  1123.  
  1124.  * Function: store-match-data MATCH-LIST
  1125.      This function sets the match data within Emacs Lisp from the
  1126.      elements of MATCH-LIST, which should be a list created by a
  1127.      previous call to `match-data'.
  1128.  
  1129.      `store-match-data' may be used together with `match-data' to
  1130.      perform a search without changing the `match-data'.  This is
  1131.      useful when such searches occur in subroutines whose callers may
  1132.      not expect searches to go on.  Here is how:
  1133.  
  1134.           (let ((data (match-data)))
  1135.             (unwind-protect
  1136.                 ... ; May change the original match data.
  1137.               (store-match-data data)))
  1138.  
  1139.      All asynchronous process functions (filters and sentinels) and
  1140.      some modes that use `recursive-edit' should save and restore the
  1141.      match data if they do a search or if they let the user type
  1142.      arbitrary commands.
  1143.  
  1144.      Here is a function which will restore the match data if the
  1145.      buffer associated with it still exists.
  1146.  
  1147.           (defun restore-match-data (data)
  1148.             "Restore the match data DATA unless the buffer is missing."
  1149.             (catch 'foo
  1150.               (let ((d data))
  1151.                 (while d
  1152.                   (and (car d)
  1153.                        (null (marker-buffer (car d)))
  1154.                        ;; match-data buffer is deleted.
  1155.                        (throw 'foo nil))
  1156.                   (setq d (cdr d)))
  1157.                 (store-match-data data))))
  1158.  
  1159.  
  1160. 
  1161. File: elisp,  Node: Standard Regexps,  Next: Searching and Case,  Prev: Saving Match Data,  Up: Searching and Matching
  1162.  
  1163. Standard Regular Expressions Used in Editing
  1164. ============================================
  1165.  
  1166.  * Variable: page-delimiter
  1167.      This is the regexp describing line-beginnings that separate
  1168.      pages.  The default value is `"^\014"' (i.e., `"^^L"' or
  1169.      `"^\C-l"').
  1170.  
  1171.  * Variable: paragraph-separate
  1172.      This is the regular expression for recognizing the beginning of
  1173.      a line that separates paragraphs.  (If you change this, you may
  1174.      have to change `paragraph-start' also.)  The default value is
  1175.      `"^[ \t\f]*$"', which is a line that consists entirely of
  1176.      spaces, tabs, and form feeds.
  1177.  
  1178.  * Variable: paragraph-start
  1179.      This is the regular expression for recognizing the beginning of
  1180.      a line that starts *or* separates paragraphs.  The default value
  1181.      is `"^[ \t\n\f]"', which matches a line starting with a space,
  1182.      tab, newline, or form feed.
  1183.  
  1184.  * Variable: sentence-end
  1185.      This is the regular expression describing the end of a sentence.
  1186.      (All paragraph boundaries also end sentences, regardless.)  The
  1187.      default value is:
  1188.  
  1189.           "[.?!][]\"')}]*\\($\\|\t\\| \\)[ \t\n]*"
  1190.  
  1191.      This means a period, question mark or exclamation mark, followed
  1192.      by a closing brace, followed by tabs, spaces or new lines.
  1193.  
  1194.      For a detailed explanation of this regular expression, see *Note
  1195.      Regexp Example::.
  1196.  
  1197.  
  1198. 
  1199. File: elisp,  Node: Searching and Case,  Prev: Standard Regexps,  Up: Searching and Matching
  1200.  
  1201. Searching and Case
  1202. ==================
  1203.  
  1204.    By default, searches in Emacs ignore the case of the text they are
  1205. searching through; if you specify searching for `FOO', then `Foo' or
  1206. `foo' is also considered a match.  Regexps, and in particular
  1207. character sets, are included: thus, `[aB]' would match `a' or `A' or
  1208. `b' or `B'.
  1209.  
  1210.    If you do not want this feature, set the variable
  1211. `case-fold-search' to `nil'.  Then all letters must match exactly,
  1212. including case.  This is a per-buffer-local variable; altering the
  1213. variable affects only the current buffer.  (*Note Intro to
  1214. Buffer-Local::.)  Alternatively, you may change the value of
  1215. `default-case-fold-search', which is the default value of
  1216. `case-fold-search' for buffers that do not override it.
  1217.  
  1218.  * User Option: case-replace
  1219.      This variable determines whether `query-replace' should preserve
  1220.      case in replacements.  If the variable is `nil', then case need
  1221.      not be preserved.
  1222.  
  1223.  * User Option: case-fold-search
  1224.      This buffer-local variable determines whether searches should
  1225.      ignore case.  If the variable is `nil' they do not ignore case;
  1226.      otherwise they do ignore case.
  1227.  
  1228.  * Variable: default-case-fold-search
  1229.      The value of this variable is the default value for
  1230.      `case-fold-search' in buffers that do not override it.  This is
  1231.      the same as `(default-value 'case-fold-search)'.
  1232.  
  1233.  
  1234.